package cn.lanchengkeji.datafillingsystem.utils;

import org.apache.commons.lang3.RandomStringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class BusinessUtils {
    public static final String ORDER_NO_PREFIX = "11";
    public static final String YINLIAN_ORDER_NO_PREFIX = "11AV";// 银联测试msgSrcId，前四位必须使用这个
    public static final String WITHDRAW_NO_PREFIX = "12";
    public static final String SERVICE_NO_PREFIX = "21";
    public static final String RECHARGE_NO_PREFIX = "22";
    public static final String COMMISSION_NO_PREFIX = "23";
    public static final String ACHIEVEMENT_NO_PREFIX = "24";
    public static final String REFUND_NO_PREFIX = "25";
    public static final String BEAN_ADD_NO_PREFIX = "31";
    public static final String BEAN_SUB_NO_PREFIX = "32";
    public static final String PLUS_ORDER_NO_PREFIX = "41";
    public static final String COUPON_PREFIX = "A";
    public static final String FREIGHT_COUPON_PREFIX = "B";
    public static final String BATCH_NO_PREFIX = "BN";
    public static final String STORE_NO_PREFIX = "M";
    public static final String SUPPLIER_NO_PREFIX = "S";

    public static String generatorYinlianOrderNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return YINLIAN_ORDER_NO_PREFIX + dateStr + random;
    }
    public static String generatorSubOrderNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return "1000" + dateStr + random;
    }
    public static String generatorStoreNo(){
        int len = 5;
        char c[] = "1234567890".toCharArray();
        String random = RandomStringUtils.random(len, c);
        return STORE_NO_PREFIX + random;
    }
    public static String generatorSupplierCode(){
        int len = 5;
        char c[] = "1234567890".toCharArray();
        String random = RandomStringUtils.random(len, c);
        return SUPPLIER_NO_PREFIX + random;
    }
    public static String generatorOrderNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return ORDER_NO_PREFIX + dateStr + random;
    }
    public static String generatorNetPayNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return dateStr + random;
    }
    public static String generatorSeq(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return dateStr + random;
    }
    public static String generatorRechargeNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return RECHARGE_NO_PREFIX + dateStr + random;
    }
    public static String generatorServiceNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return SERVICE_NO_PREFIX + dateStr + random;
    }
    public static String generatorWithdrawNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return WITHDRAW_NO_PREFIX + dateStr + random;
    }
    public static String generatorBatchNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date());
        String random = RandomStringUtils.random(3,false,true);
        return BATCH_NO_PREFIX + dateStr + random;
    }
    public static String generatorVerifyCode(){
        String random = RandomStringUtils.random(6,false,true);
        return random;
    }
    public static String generatorDiscountCouponNo(){
        int len = 24;
        char c[] = "ABCDEFGHJKLMNPQRSTUVWXYZ1234567890".toCharArray();
        String random = RandomStringUtils.random(len, c);
        return COUPON_PREFIX + random;
    }
    public static String generatorStoreRecommendCode(){
        int len = 8;
        char c[] = "ABCDEFGHJKLMNPQRSTUVWXYZ1234567890".toCharArray();
        String random = RandomStringUtils.random(len, c);
        return FREIGHT_COUPON_PREFIX + random;
    }
    public static String generatorAgentCode(){
        int len = 8;
        char c[] = "ABCDEFGHJKLMNPQRSTUVWXYZ1234567890".toCharArray();
        String random = RandomStringUtils.random(len, c);
        return FREIGHT_COUPON_PREFIX + random;
    }
    public static void main(String[] args) {
        System.out.println(generatorDiscountCouponNo());
//        System.out.println(generatorFreightCouponNo());
    }
}
